#ifndef _VMAPDLG_H
#define _VMAPDLG_H

#include  "config.h"

class CVMapDlg : public CDialogImpl<CVMapDlg>, 
                 public CWinDataExchange<CVMapDlg>
{
	
public:
    enum { IDD = IDD_VMAP };
 
    BEGIN_MSG_MAP(CImageSizeDlg)
        MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
        MESSAGE_HANDLER(WM_CLOSE, OnClose)
		COMMAND_ID_HANDLER(IDOK, OnOK)
        COMMAND_ID_HANDLER(IDCANCEL, OnCancel)

		//REFLECT_NOTIFICATIONS ()
	END_MSG_MAP()
 
    LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
        CenterWindow();
		//Config::g_configFile.read();
		
		aInterval = (Config::VTM_Interval)/5-1;
        //Convert real interval to index.
		ePostion = (Config::VTM_EPosition)==true?0:1;
		eName = (Config::VTM_ENames)==true?0:1;
		Value = (Config::VTM_VALDisplay)==true?0:1;
		Interpolation = Config::VTM_Interpolation;
		Resolution = Config::VTM_Resolution-1;

		DoDataExchange(FALSE);
        return TRUE;    // let the system set the focus

    }


    LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
        EndDialog(IDCANCEL);
        return 0;
    }

	LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
    {
        EndDialog(wID);
        return 0;
    }
	LRESULT OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
    {
		if(DoDataExchange(TRUE)==0)
		{
			MessageBox(_T("Invalid value of width or height."));
			return 0;
		}

		Config::VTM_Interval = (aInterval+1)*5;
		//Convert index to real interval
		Config::VTM_EPosition = ePosition==0?true:false;
		Config::VTM_ENames = eName==0?true:false;
		Config::VTM_VALDisplay = Value==0?true:false;
		Config::VTM_Interpolation = Interpolation;
		Config::VTM_Resolution = Resolution+1;
		
		//Config::g_configFile.write();
        EndDialog(wID);
        return 0;
    }

	BEGIN_DDX_MAP(CVMapDlg)
		DDX_RADIO(IDC_RADIO1,aInterval);
		DDX_RADIO(IDC_RADIO14,ePosition);
		DDX_RADIO(IDC_RADIO23,eName);
		DDX_RADIO(IDC_RADIO25,Value);
		DDX_RADIO(IDC_RADIO15,Interpolation);
		DDX_RADIO(IDC_RADIO20,Resolution);
		//DDX_CONTROL(IDC_COMBOCOLOR, cb_color);
    END_DDX_MAP()

protected:
	int aInterval,ePosition,eName,Value,Interpolation,Resolution;
public:

};
#endif